﻿Type=Activity
Version=5.8
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: False
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Private tmrautoswip As Timer
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Private pbotkecheng As Panel
	Private pbotshouye As Panel
	Private pbotwo As Panel
	Private pbotxiaoxi As Panel
	Private pmain As Panel
	Private lLastBackPress As Long
	'主页面容器
	Private mps(4) As Panel
	Private ptitleedtsearchteacher As EditText
	Private lbllocation As Label
	Private ptitleivfinder As ImageView
	Private svmp1 As ScrollView
	Private mp1vplunbo As AHViewPager
	Private mp1vplunboindp As Panel
	Private mp1vplunbopages As AHPageContainer
	Private mp1innerIndP As Panel
	Dim oks1 As OKS
	Private pkecheng(2) As Panel '科目列表容器
	Private lstSubjects As List
	Private vpkecheng As AHViewPager
	Private vpkechengpages As AHPageContainer
	Private vpkechengind As Panel
	Private mp1innerkecheng As Panel
	Private pmingshituijian As Panel
	Private pline As Panel
	Private itemteacherdistence As Label
	Private itemkcteacherheader As RIV
	Private myCalView As clsCalendar
	Private mp2title As Label
	Private mp2inCompleteLbl As Label
	Private mp2selectedDatelbl As Label
	Private mp2kechenglistview As clsCustomListView
	Private mp3lblmycontract As Label
	Private mp3lblmymsg As Label
	Private mp3titlepanel As Panel
	Private vpmsg As AHViewPager
	Private vpmsgPages As AHPageContainer
	Private cdMsgTabPre,cdMsgTabNor As ColorDrawable
	Private mp3mymsglv,mp3mycontactlv As clsCustomListView
	Private itemmymsgrecentmsg As Label
	Private itemmymsgteachername As Label
	Private itemmymsgtime As Label
	Private itemmymsgteacherheader As RIV
	Private mp4myheader As RIV
	Private mp4mymenulist As clsCustomListView
	Private itemmymenutitle As Label
	Private itemmymenuleftiv As ImageView
	Private mp4myinfofavteachernumlbl As Label
	Private mp4myinfoordernumlbl As Label
	Private mp4myinfoyhqnumlbl As Label
	Private mp4myinfoyuelbl As Label
	Dim gf As GalleryFinal
	Private mi As myInfo
	'mstj
	Private itemstartprice As Label
	Private itemteacheage As Label
	Private itemteacheradwords As Label
	Private itemteacherdistence As Label
	Private itemteachernickname As Label
	Private itemteaheadimg As RIV
	Private mstjlst As List
	Private itemrate As Label
	Private itemsex As ImageView
	Private mp4mynickname As Label
	Private itemkcstatus As Label
	Private itemkctime As Label
	Private itemkcshangmenaddr As Label
	Private itemkcteachername As Label
	Private itemkcteachersex As ImageView
	Private qqmta As QQMTA
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("laymain")
	initviews
	'qqmta
	qqmta.Initialize("qqmta")
	qqmta.initNativeCrashReport("init so")
	qqmta.DebugEnable=True
	qqmta.trackCustomEvent("onCreate")
	qqmta.AutoExceptionCaught=True
	qqmta.StatSendStrategy=qqmta.SR_INSTANT
	'qqmta end
End Sub
#Region test
Sub testmenu
	gf.Init("gf",gf.DARK)
	Activity.AddMenuItem("single","a1")
	Activity.AddMenuItem("muti","a2")
	Activity.AddMenuItem("camera","a3")
End Sub
Sub a1_Click
	'gf.openGallerySingle(1)
	Dim gc As FunctionConfig_gf
	gc.init
	gc.EnablePreview=True
	gc.EnableCamera=True
	gf.openGallerySingle2(1,gc.Build)
	Log("a1")
End Sub
Sub a2_Click
	gf.openGalleryMuti(2,4)
End Sub
Sub a3_Click
	gf.openCamera(3)
End Sub
Sub gf_onHanlderSuccess(reqeustCode As Int,resultList As List)
	Log("gf_onHanlderSuccess reqeustCode:"&reqeustCode)
	Dim tp As PhotoInfo
	For i=0 To resultList.Size-1
		tp=resultList.Get(i)
		Log(tp.PhotoPath)
	Next
End Sub

Sub gf_onHanlderFailure(requestCode As Int,errorMsg As String)
	Log("gf_onHanlderFailure requestCode:"&requestCode&CRLF&errorMsg)
End Sub
#end region
Sub initviews
	lstSubjects=g_store.conf.Get(comm.S_SUBJECTS)
	
	'页面容器初始化
	For i=0 To mps.Length-1
		mps(i).Initialize("")
		pmain.AddView(mps(i),0,0,100%x,pmain.Height)
	Next
	mps(0).LoadLayout("mp1")
	mps(1).LoadLayout("mp2")
	mps(2).LoadLayout("mp3")

	'首页顶部的组建
	Dim cd As ColorDrawable
	cd.Initialize(Colors.White,20)
	ptitleedtsearchteacher.Background=cd
	comm.SetPadding(ptitleedtsearchteacher,ptitleivfinder.Width+5dip,0,0,0)
	lbllocation.Text=g_store.conf.GetDefault("curcity","乌鲁木齐")&" v"
	svmp1.Panel.LoadLayout("mp1inner")
	'轮播测试数据填充
	mp1vplunbopages.Initialize
	'Dim imgs() As String=Array As String("http://img.alicdn.com/tps/TB1IJaqLVXXXXXEXVXXXXXXXXXX-770-360.jpg_.webp","http://img.alicdn.com/tps/TB1C8XGLVXXXXXkaXXXXXXXXXXX-770-360.jpg_.webp","http://img.alicdn.com/tps/TB17nlNLVXXXXXAXFXXXXXXXXXX-770-360.jpg_.webp","https://gju1.alicdn.com/tps/i2/188290172382309919/TB2jHVPkVXXXXXoXpXXXXXXXXXX_!!0-juitemmedia.jpg_400x400Q90.jpg_.webp","https://gju3.alicdn.com/tps/i4/134980173381498336/TB20O6HkVXXXXcjXXXXXXXXXXXX_!!0-juitemmedia.jpg_400x400Q90.jpg_.webp","https://img10.360buyimg.com/imgzone/jfs/t2323/264/1806765417/56695/e773d556/5684d83fNa6d75cd6.jpg","https://img10.360buyimg.com/imgzone/jfs/t2347/276/1186662178/119320/fd8d0ea7/5684d840Nc67801a7.jpg")
	Dim banner As List=g_store.conf.Get("banner")
	For i=0 To banner.Size-1
		Dim p As Panel
		p.Initialize("")
		Dim bimg As BetterImageView
		bimg.Initialize("imglunbo")
		bimg.Tag=i
		bimg.ScaleType=bimg.SCALETYPE_FIT_XY
		p.AddView(bimg,0,0,-1,-1)
		comm.loadimg(banner.Get(i),bimg)
		mp1vplunbopages.AddPage(p,"")
	Next
	mp1vplunbo.PageContainer=mp1vplunbopages
	Dim nkd As Int=mp1vplunbopages.Count*16dip
	mp1vplunboindp=pageind.CreatePageIndicator(mp1vplunbopages.Count,comm.InactiveBitmap,nkd,16dip)
	mp1innerIndP.AddView(mp1vplunboindp,(100%x-nkd)/2,mp1innerIndP.Height-26dip,nkd,16dip)
	mp1vplunboindp.BringToFront
	mp1vplunbo_PageChanged(0)
	pbotshouye_Click
	tmrautoswip.Initialize("tmrauto",3000)
	tmrautoswip.Enabled=True
	'科目模块动态构建
	
	Dim nimgkd As Int=15%x
	Dim nimgjg As Int=(100%x-nimgkd*4)/8
	Dim nPointer As Int=0
	Dim nl,nt As Int
	vpkechengpages.Initialize
	pkecheng(0).Initialize("")	
	vpkechengpages.AddPage(pkecheng(0),"")
	If lstSubjects.Size>6 Then
		pkecheng(1).Initialize("")
		vpkechengpages.AddPage(pkecheng(1),"")	
	End If
	nt=nimgjg
	nl=nimgjg
	For i=0 To lstSubjects.Size-1
		Dim rimg As BetterImageView
		rimg.Initialize("imgkc")
		'rimg.DesignerCreateView(
		rimg.ScaleType=rimg.SCALETYPE_FIT_XY
		rimg.Tag=i
		If i<8 Then
			pkecheng(0).AddView(rimg,nl,nt,nimgkd,nimgkd)
		Else
			pkecheng(1).AddView(rimg,nl,nt,nimgkd,nimgkd)
		End If
		Dim st=lstSubjects.Get(i) As Subject
		comm.loadimg(st.img,rimg)
		Dim lbl As Label
		lbl.Initialize("")
		lbl.Text=st.name
		'Log(i&" "&subjectnames(i))
		lbl.TextColor=Colors.Black
		lbl.Gravity=Gravity.CENTER
		If i<8 Then
			pkecheng(0).AddView(lbl,nl,nt+nimgkd,nimgkd,20dip)
		Else
			pkecheng(1).AddView(lbl,nl,nt+nimgkd,nimgkd,20dip)
		End If
		nl=rimg.Left+rimg.Width+nimgjg*2
		If nPointer=3 Then
			nl=nimgjg
			nt=mp1innerkecheng.Height/2
		End If
		If nPointer=7 Then
			nPointer=0
			nl=nimgjg
			nt=nimgjg
		Else
			nPointer=nPointer+1
		End If
	Next
	vpkecheng.PageContainer=vpkechengpages
	Dim indkd As Int=vpkechengpages.Count*16dip
	vpkechengind=pageind.CreatePageIndicator(vpkechengpages.Count,comm.InactiveBitmap,indkd,16dip)
	mp1innerkecheng.AddView(vpkechengind,(100%x-indkd)/2,mp1innerkecheng.Height-26dip,indkd,16dip)
	vpkechengind.BringToFront
	vpkecheng_PageChanged(0)
	
	'名师推荐
	CreateItemTeacher
	
	'课程表
	Dim nYear,nMonth As Int
	nYear=DateTime.GetYear(DateTime.Now)
	nMonth=DateTime.GetMonth(DateTime.Now)
	myCalView.setTime(nYear,nMonth)
	mp2title.Text=$"${nYear}年$1.0{nMonth}月 v"$
	Dim nh As Int=80dip
	mp2kechenglistview.Add(CreateItemEmpty(100%x,nh),nh,-1)
	
	'消息
	cdMsgTabPre.Initialize2(0xFF009688,5,0,0)
	cdMsgTabNor.Initialize2(Colors.White,5,1dip,Colors.Black)
	mp3mymsglv.Initialize(Me,"mymsglv")
	mp3mycontactlv.Initialize(Me,"mycontlv")
	vpmsgPages.Initialize
	Dim p,p2 As Panel
	p.Initialize("")
	p2.Initialize("")
	vpmsgPages.AddPage(p,"")
	vpmsgPages.AddPage(p2,"")
	vpmsg.PageContainer=vpmsgPages
	p.AddView(mp3mymsglv.AsView,0,0,100%x,vpmsg.Height)
	p2.AddView(mp3mycontactlv.AsView,0,0,100%x,vpmsg.Height)
	'消息填充
	Dim nmsgH As Int=75dip
	For i=0 To Rnd(3,6)
		mp3mymsglv.Add(createitemmymsg(100%x,nmsgH),nmsgH,i)
	Next
	fillmyinfo
	comm.aio(Activity)
	notifiy	
End Sub
Sub notifiy
	If Starter.nUnrateOrd>0 Then
		Msgbox("您当前有未评价的订单，请及时评价哦!","提示")
	End If
End Sub
#Region parse
Private Sub parseKCLst(str As String)
	Dim parser As JSONParser 
	parser.Initialize(str) 
	Dim nh As Int=80dip
	mp2kechenglistview.Clear
	Dim root As Map = parser.NextObject 
	Dim data As List = root.Get("data") 
	If data.IsInitialized And data.Size>0 Then
		For Each coldata As Map In data 
		    Dim image As String = comm.combinPic(coldata.Get("image"))
		    Dim sd_start_time As String = coldata.Get("sd_start_time") 
		    Dim finished_time As String = coldata.Get("finished_time") 
		    Dim kc_title As String = coldata.Get("kc_title") 
		    Dim tuikuan_time As String = coldata.Get("tuikuan_time") 
		    Dim usertel As String = coldata.Get("usertel") 
		    Dim sd_mode As String = coldata.Get("sd_mode") 
		    Dim sd_hour As String = coldata.Get("sd_hour") 
		    Dim trd_id As String = coldata.Get("trd_id") 
		    Dim sd_money As String = coldata.Get("sd_money") 
		    Dim sd_end_time As String = coldata.Get("sd_end_time") 
		    Dim fl_title As String = coldata.Get("fl_title") 
		    Dim riqi As String = coldata.Get("riqi") 
		    Dim id As String = coldata.Get("id") 
			Dim sex As String = coldata.Get("sex") 
		    Dim add_time As String = coldata.Get("add_time") 
		    Dim kc_address As String = coldata.Get("kc_address") 
		    Dim order_sn As String = coldata.Get("order_sn") 
		    Dim status As String = coldata.Get("status") 
		    Dim username As String = coldata.Get("username") 
			Dim kci As kcItem
			kci.Initialize
			kci.tecImg=image
			kci.shangmenfangshi=sd_mode
			kci.kemu=fl_title
			kci.time=sd_end_time
			kci.tecname=username
			kci.status=status
			kci.sex=sex
			kci.trdid=trd_id
			kci.addr=kc_address
	'		If status.EqualsIgnoreCase("1") Then
	'			kci.status="已完课"
	'		Else
	'			kci.status="未上课"
	'		End If
			mp2kechenglistview.Add(createkcitem(kci,100%x,nh),nh,kci)	
		Next 
	Else
		mp2kechenglistview.Add(CreateItemEmpty(100%x,nh),nh,-1)	
	End If
	mp2kechenglistview.JumpToItem(0)
	'Dim status As String = root.Get("status") 
	
End Sub
Private Sub parseTecDetail(str As String)
	Dim parser As JSONParser 
	parser.Initialize(str) 
	Dim root As Map = parser.NextObject 
	Dim data As List = root.Get("data") 
	For Each coldata As Map In data 
	    Dim note As String = coldata.Get("note") 
	    Dim city As String = coldata.Get("city") 
	    Dim is_user_note As String = coldata.Get("is_user_note") 
	    Dim is_xw As String = coldata.Get("is_xw") 
	    Dim autograph As String = coldata.Get("autograph") 
	    Dim is_xw_note As String = coldata.Get("is_xw_note") 
	    Dim usertel As String = coldata.Get("usertel") 
	    Dim experience As String = coldata.Get("experience") 
	    Dim hp_lv As String = coldata.Get("hp_lv") 
	    Dim jianjie As String = coldata.Get("jianjie") 
	    Dim stu_c As String = coldata.Get("stu_c") 
	    Dim is_zs As String = coldata.Get("is_zs") 
	    Dim fl_title As String = coldata.Get("fl_title") 
	    Dim fmode As String = coldata.Get("fmode") 
	    Dim js_id As String = coldata.Get("js_id") 
	    Dim id As String = coldata.Get("id") 
	    Dim hp_c As String = coldata.Get("hp_c") 
	    Dim is_user As String = coldata.Get("is_user") 
	    Dim is_zg As String = coldata.Get("is_zg") 
	    Dim image As String = coldata.Get("image") 
	    Dim js_xj As String = coldata.Get("js_xj") 
	    Dim address As String = coldata.Get("address") 
	    Dim sex As String = coldata.Get("sex") 
	    Dim locking As String = coldata.Get("locking") 
	    Dim photo As String = coldata.Get("photo") 
	    Dim banner As List = coldata.Get("banner") 
	    For Each colbanner As Map In banner 
	        Dim into_money As String = colbanner.Get("into_money") 
	        Dim city As String = colbanner.Get("city") 
	        Dim keshi As String = colbanner.Get("keshi") 
	        Dim remark As String = colbanner.Get("remark") 
	        Dim time As String = colbanner.Get("time") 
	        Dim usertel As String = colbanner.Get("usertel") 
	        Dim order_id As String = colbanner.Get("order_id") 
	        Dim nianji As String = colbanner.Get("nianji") 
	        Dim hy_school As String = colbanner.Get("hy_school") 
	        Dim username As String = colbanner.Get("username") 
	    Next 
	    Dim is_zs_note As String = coldata.Get("is_zs_note") 
	    Dim quyu As String = coldata.Get("quyu") 
	    Dim addtime As String = coldata.Get("addtime") 
	    Dim grade As String = coldata.Get("grade") 
	    Dim is_sh As String = coldata.Get("is_sh") 
	    Dim hpz_c As String = coldata.Get("hpz_c") 
	    Dim is_zg_note As String = coldata.Get("is_zg_note") 
	    Dim kechen As List = coldata.Get("kechen") 
	    For Each colkechen As Map In kechen 
	        Dim kc_start_time As String = colkechen.Get("kc_start_time") 
	        Dim kc_end_time As String = colkechen.Get("kc_end_time") 
	        Dim is_youhui As String = colkechen.Get("is_youhui") 
	        Dim kc_title As String = colkechen.Get("kc_title") 
	        Dim kc_money As String = colkechen.Get("kc_money") 
	        Dim kc_mode As String = colkechen.Get("kc_mode") 
	        Dim kc_grade As String = colkechen.Get("kc_grade") 
	        Dim kc_money_st As String = colkechen.Get("kc_money_st") 
	        Dim addtime As String = colkechen.Get("addtime") 
	        Dim js_id As String = colkechen.Get("js_id") 
	        Dim kc_type As String = colkechen.Get("kc_type") 
	        Dim id As String = colkechen.Get("id") 
	        Dim kc_money_bk As String = colkechen.Get("kc_money_bk") 
	        Dim kc_address As String = colkechen.Get("kc_address") 
	        Dim kc_hour As String = colkechen.Get("kc_hour") 
	        Dim status As String = colkechen.Get("status") 
	    Next 
	    Dim pl As List = coldata.Get("pl") 
	    For Each colpl As List In pl 
	        For Each colcolpl As Map In colpl 
	            Dim comment_person As String = colcolpl.Get("comment_person") 
	            Dim image As String = colcolpl.Get("image") 
	            Dim comment_xj As String = colcolpl.Get("comment_xj") 
	            Dim city As String = colcolpl.Get("city") 
	            Dim usertel As String = colcolpl.Get("usertel") 
	            Dim comment_addtime As String = colcolpl.Get("comment_addtime") 
	            Dim comment_id As String = colcolpl.Get("comment_id") 
	            Dim nianji As String = colcolpl.Get("nianji") 
	            Dim comment_huifu_id As String = colcolpl.Get("comment_huifu_id") 
	            Dim kc_id As String = colcolpl.Get("kc_id") 
	            Dim children As List = colcolpl.Get("children") 
	            Dim comment_type As String = colcolpl.Get("comment_type") 
	            Dim comment_content As String = colcolpl.Get("comment_content") 
	            Dim id As String = colcolpl.Get("id") 
	            Dim username As String = colcolpl.Get("username") 
	        Next 
	    Next 
	    Dim banner_count As String = coldata.Get("banner_count") 
	    Dim seniority As String = coldata.Get("seniority") 
	    Dim username As String = coldata.Get("username") 
	    Dim is_tuijian As String = coldata.Get("is_tuijian") 
	Next 
	Dim status As String = root.Get("status") 

End Sub

#End Region
#Region ItemCreates
Private Sub CreateItemTeacher
	Dim nmsgd As Int=120dip
	Dim nmsjg As Int=5dip
	Dim nt As Int=pline.Top+1dip
	mstjlst=g_store.conf.Get("mstjlst")
	If mstjlst.IsInitialized=False Then
		 comm.TL("推荐列表出错:not init")
		 Return
	End If
	For i=0 To mstjlst.Size-1
		Dim p As Panel
		p.Initialize("pitemteacher")
		pmingshituijian.AddView(p,0,nt,100%x,nmsgd)
		p.LoadLayout("itemteacher")
		'filldata
		Dim t As Teacher=mstjlst.Get(i)
		p.Tag=t.ID
		itemstartprice.Text="￥"&t.startPrice
		itemteacheage.Text=t.teacheAge&"年"
		itemteacheradwords.Text=t.adWords
		itemteacherdistence.Text=t.distence
		itemteachernickname.Text=t.nickname
		comm.loadimg(t.headimg,itemteaheadimg)
		itemrate.Text="评论数:"&t.rateNum&"条 好评率:"&t.ratePercent&" 学生数:"&t.stunum
		If t.sexMen Then
			itemsex.Bitmap=comm.bmpSexMan
		Else
			itemsex.Bitmap=comm.bmpSexWoman
		End If
		Dim n As Int=comm.su.MeasureMultilineTextHeight(itemteachernickname,itemteachernickname.Text)
		itemteachernickname.Width=n*itemteachernickname.Text.Trim.Length '挨着排列
		itemsex.Left=itemteachernickname.Width+itemteachernickname.Left
		nt=nt+nmsgd+nmsjg
		'nmsgd=itemteacherdistence.Height+itemteacherdistence.Top+nmsjg
		
	Next
	pmingshituijian.Height=pmingshituijian.Height+nmsgd*i+nmsjg*(i-1)
	svmp1.Panel.Height=pmingshituijian.Top+pmingshituijian.Height
End Sub
Private Sub CreateItemEmpty(w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemempty")
	p.RemoveView
	Return p
End Sub
Private Sub createkcitem(kci As kcItem, w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemkecheng")
	comm.loadimg(comm.S_TESTTEACHERHEADER,itemkcteacherheader)
	p.RemoveView
	itemkctime.Text=kci.time
	itemkcshangmenaddr.Text=kci.addr
	comm.loadimg(kci.tecImg,itemkcteacherheader)
	itemkcteachername.Text=kci.grade&kci.kemu&kci.tecname
	itemkcstatus.Text=kci.status
	If kci.sex.EqualsIgnoreCase("1") Then
		itemkcteachersex.Bitmap=comm.bmpSexMan
	Else
		itemkcteachersex.Bitmap=comm.bmpSexWoman
	End If
	Dim n As Int=comm.su.MeasureMultilineTextHeight(itemkcteachername,itemkcteachername.Text)
	itemkcteachername.Width=n*itemkcteachername.Text.Trim.Length '挨着排列
	itemkcteachersex.Left=itemkcteachername.Left+itemkcteachername.Width
	p.Tag=kci
	Return p
End Sub
Private Sub CreateMyinfoPanel(w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("mp4myinfoinner")
	p.RemoveView
'	itemkctime
	Return p
End Sub
Private Sub createitemmymenu(img As String,str As String,w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemmymenu")
	itemmymenuleftiv.Bitmap=LoadBitmap(File.DirAssets,img&".png")
	itemmymenuleftiv.Gravity=Gravity.FILL
	itemmymenutitle.Text=str
	p.RemoveView
	Return p
End Sub
Private Sub createitemmymenu_phone(img As String,str As String,w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemmymenuphone")
	itemmymenuleftiv.Bitmap=LoadBitmap(File.DirAssets,img&".png")
	itemmymenutitle.Text=str
	p.RemoveView
	Return p
End Sub
Sub createitemmymsg(w As Int,h As Int) As Panel
	Dim p As Panel
	p.Initialize("")
	Activity.AddView(p,0,0,w,h)
	p.LoadLayout("itemmymsg")
	comm.loadimg(comm.S_TESTTEACHERHEADER,itemmymsgteacherheader)	
	p.RemoveView
	Return p
End Sub
#End Region
'恢复时刷新一遍个人信息
Sub Activity_Resume
	Try
		'callrefushmyinfolocal
		callrefushmyinfo
	Catch
		Log(LastException.Message)
	End Try
'	If g_store.conf.GetDefault("islogin",False) Then	'加载新的图片
'		comm.loadimg_nocache("file://"&File.Combine(actModifyMyInfo.sDir,actModifyMyInfo.sName),mp4myheader)
'		callrefushmyinfo
'	End If
'	Dim url As String
'	Select Rnd(0,3)
'	Case 0
'		url="http://wallcoo.com/nature/Summer_Fantasy_Landscapes/wallpapers/1680x1050/Summer_Fantasy_landscape_by_photo_manipulation_13255063.jpg"
'	Case 1
'		url="http://pic.xiudodo.net/figure/00/00/07/01/52/5155adc7e4b7cde.jpg"
'	Case 2
'		url="http://img01.sogoucdn.com/app/a/100540002/465331.jpg"
'	End Select
'	comm.ShowPic(url)
'	'StartActivity(actModifyEval)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
#Region mp1
'mp1更多老师
Sub lblmoreteacher_Click
	StartActivity(actFindTeacher)	
End Sub
Sub pitemteacher_Click
	Dim v As View=Sender
	Dim tecid As Int=v.Tag
	comm.TL("tecid:"&tecid)
'	Log(tecid)
'	ToastMessageShow(tecid&" click",False)
	comm.showTecDetail(tecid)
	'StartActivity(actTeacherDetail)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
	If KeyCode==KeyCodes.KEYCODE_BACK Then
		If DateTime.Now-lLastBackPress<3000 Then
			'连按退出
			StopService(Starter)
			Activity.Finish
			ExitApplication
			Return False
		Else
			ToastMessageShow("再次按下返回可退出程序",False)
			lLastBackPress=DateTime.Now
			Return True
		End If
		Return False 
	End If
	Return False
End Sub
'根据序号修改底部菜单状态
Sub chgBotPnlState(n As Int)
	'切换页面内容
	If False=chgPmain(n) Then
		Return
	End If
	Dim ps(4) As Panel=Array As Panel(pbotshouye,pbotkecheng,pbotxiaoxi,pbotwo)
	Dim nNormalClr As Int=Colors.Black
	Dim nPressedClr As Int =0xFF009688
	If n>ps.Length-1 Then
		Log($"chgBotPnlState序号:${n}非法"$)
		Return
	End If
	Dim p As Panel
	Dim lbl As Label
	Dim btn As Button
	For i=0 To ps.Length-1
		p=ps(i)
		For Each v As View In p.GetAllViewsRecursive
			'这里如果用 is label is button的话 button也会被识别为button
			If GetType(v).Contains("Button") Then
				'按钮
				btn=v
				If i==n Then
					btn.Enabled=False
				Else
					btn.Enabled=True
				End If
			else If GetType(v).Contains("TextView") Then
				'文字标签
				lbl=v
				If i==n Then 
					lbl.TextColor=nPressedClr
				Else
					lbl.TextColor=nNormalClr
				End If 
			End If
		Next	
	Next
	
End Sub
Sub pbotshouye_Click
	chgBotPnlState(0)
End Sub

Sub pbotkecheng_Click
	chgBotPnlState(1)
End Sub

Sub pbotxiaoxi_Click
	chgBotPnlState(2)
End Sub

Sub pbotwo_Click
	chgBotPnlState(3)
End Sub
'切换页面内容
Sub chgPmain(idx As Int) As Boolean
	Select idx
	Case 1 '课程和消息要求登录
		If Not(comm.isLogin) Then 
			requireLogin
			Return False
		End If
	Case 2
		If Not(comm.isLogin) Then 
			requireLogin
			Return False
		End If
	Case 3
		callrefushmyinfo
	End Select
	For i=0 To mps.Length-1
		If idx==i Then
			mps(i).Visible=True
		Else
			mps(i).Visible=False
		End If
	Next
	Return True
End Sub
Private Sub requireLogin
	comm.TL("请先登录")
	StartActivity(actLogin)

End Sub
Sub callrefushmyinfo
	If g_store.conf.GetDefault("islogin",False) Then
		'Log("req refushmyinfo")
		callrefushmyinfolocal
		ParseHelper.doGetReq(Me,"refushmyinfo",comm.getApi(comm.apiIdx.REFUSHMYINFO),Null)
	End If
End Sub
Sub callrefushmyinfolocal
	If g_store.conf.GetDefault("islogin",False) Then
		'Log("req refushmyinfo")
		'ParseHelper.doGetReq(Me,"refushmyinfo",comm.getApi(comm.apiIdx.REFUSHMYINFO),Null)
			mi=g_store.conf.Get("myinfo")
			mp4myinfofavteachernumlbl.Text=mi.favTeacherNum&"位"
			mp4myinfoordernumlbl.Text=mi.ordNum&"个"
			mp4myinfoyhqnumlbl.Text=mi.yhqNum&"张"
			mp4myinfoyuelbl.Text=mi.yue&"元"
			mp4mynickname.Text=mi.usertel
			If mi.headimg.Length>0 Then
				comm.loadimg(mi.headimg,mp4myheader)
			Else
				comm.loadimg(comm.S_TESTMYHEADER,mp4myheader)
			End If
	End If
End Sub
'切换主页
Sub vpmain_PageChanged (Position As Int)
	Log(Position)
	
End Sub

Sub vpmain_PageScrollStateChanged (State As Int)
	
End Sub

Sub lbllocation_Click
	CallSubDelayed2(actSelectCity,"reqloc",Me)
End Sub
Sub citySelected
	lbllocation.Text=g_store.conf.Get("curcity")&" v"
End Sub
'科目被点击
Sub imgkc_Click
	Dim v As View=Sender
	Dim st As Subject=lstSubjects.Get(v.Tag)
	Dim kcname As String=st.name
	g_store.put("curst",st)
	StartActivity(actFindTeacher)
	ToastMessageShow(kcname&" click",False)
	'StartActivity(acttest)
End Sub
'切换到消息页面
Sub ptitleivmsg_Click
	chgBotPnlState(2)
End Sub
Sub imglunbo_Click
	Dim v As View=Sender
	ToastMessageShow("iv:"&v.Tag&" click",False)
	Log(v.Tag)
End Sub
Sub tmrauto_Tick
	If 	mp1vplunbo.CurrentPage=mp1vplunbopages.Count-1 Then
		mp1vplunbo.CurrentPage=0
	Else
		mp1vplunbo.CurrentPage=mp1vplunbo.CurrentPage+1
	End If
End Sub
Sub mp1vplunbo_PageChanged (Position As Int)
	pageind.SetPageIndicator(mp1vplunboindp,Position,comm.ActiveBitmap,comm.InactiveBitmap)
End Sub

Sub vpkecheng_PageChanged (Position As Int)
	pageind.SetPageIndicator(vpkechengind,Position,comm.ActiveBitmap,comm.InactiveBitmap)
End Sub
#End Region

#Region mp2 课程
Private Sub reqKCLST(rq As String)
	comm.showProgress("正在获取课程列表")
	ParseHelper.doGetReq(Me,"reqkclst",comm.getApi(comm.apiIdx.REQKECHENLIST),Array As String("riqi",rq))
End Sub
Sub myCalView_CellClick (Value As Int,Str As String)
	DateTime.DateFormat="yyyy-MM-dd"
	Dim dt As Long=DateTime.DateParse(myCalView.year&"-"&myCalView.month&"-"&Value)
	Dim rq As String=DateTime.Date(dt)
	DateTime.DateFormat="yyyy年MM月dd日 课程表"	
	mp2selectedDatelbl.Text=DateTime.Date(dt)
	'请求数据
	reqKCLST(rq)
End Sub

Sub mp2inCompleteLbl_Click
	StartActivity(actUncompleteKC)
End Sub

Sub mp2title_Click
	Dim dp As DateDialog
	dp.Year=myCalView.nCurYear
	dp.Month=myCalView.nCurMonth
	dp.DayOfMonth=myCalView.nCurDay
	dp.ShowCalendar=False
	If dp.Show("请选择要显示的月份","月份","确定","取消","",Null)=DialogResponse.POSITIVE Then
		myCalView.setTime(dp.Year,dp.Month)
		mp2title.Text=$"${dp.Year}年$1.0{dp.Month}月 v"$
		mp2kechenglistview.Clear
	End If
	
End Sub
'课程被点击
Sub mp2kechenglistview_ItemClick (Index As Int, Value As Object)
	Log("L=781")
	Try
		Dim n As Int=Value
		n=n+1
	Catch
		g_store.conf.Put("curkc",Value)
		StartActivity(actKcDetail)
	End Try
	
End Sub
#End Region
#Region mp3
Sub vpmsg_PageChanged (Position As Int)
	chgMsgTitleTab(Position)
End Sub
Private Sub chgMsgTitleTab(idx As Int)
	Select idx
	Case 0
		mp3lblmymsg.Background=cdMsgTabPre
		mp3lblmymsg.TextColor=Colors.White
		mp3lblmycontract.Background=cdMsgTabNor
		mp3lblmycontract.TextColor=Colors.Black
	Case 1
		mp3lblmycontract.Background=cdMsgTabPre
		mp3lblmycontract.TextColor=Colors.White
		mp3lblmymsg.Background=cdMsgTabNor
		mp3lblmymsg.TextColor=Colors.Black
	End Select
End Sub
Sub mp3lblmymsg_Click
	vpmsg.CurrentPage=0
End Sub
'联系人项目被点击
Sub mycontlv_ItemClick (Index As Int, Value As Object)
	
End Sub
Sub mymsglv_ItemClick (Index As Int, Value As Object)
	StartActivity(actChatting)	
End Sub
Sub mp3lblmycontract_Click
	vpmsg.CurrentPage=1
End Sub
#End Region
#Region mp4
Sub mp4myheader_Click
	comm.ShowPic(mi.headimg)
	'comm.ShowPic("file://"&File.Combine(actModifyMyInfo.sDir,actModifyMyInfo.sName))
End Sub
Private Sub fillmyinfo
	'我
	mps(3).RemoveAllViews
	Dim nH As Int=60dip
	Dim nDivH As Int=10dip
	If g_store.conf.GetDefault("islogin",False) Then
		'已登录
		mi=g_store.conf.Get("myinfo")
		mps(3).LoadLayout("mp4logined")
		Dim nHMyinfo As Int=110dip
		mp4mymenulist.Clear
		mp4mymenulist.Add(CreateMyinfoPanel(100%x,nHMyinfo),nHMyinfo,0)
		mp4mymenulist.Add(createitemmymenu("ico_share","推荐给好友",100%x,nH),nH,comm.S_SHARE)
		mp4mymenulist.AddCustomDivider(nDivH)
		mp4mymenulist.Add(createitemmymenu("ico_user","个人资料",100%x,nH),nH,comm.S_PERSONALINFO)
		'mp4mymenulist.Add(createitemmymenu("test_itemleft","我关注的老师",100%x,nH),nH,comm.S_MYFAVTEACHER)
		mp4mymenulist.Add(createitemmymenu("ico_note","课程评价",100%x,nH),nH,comm.S_KECHENGRATE)
		mp4mymenulist.Add(createitemmymenu("ico_compare","在线比价",100%x,nH),nH,comm.S_COMPARE_PRICE)
		mp4mymenulist.Add(createitemmymenu("ico_news","新闻动态",100%x,nH),nH,comm.S_NEWS)
		mp4mymenulist.AddCustomDivider(nDivH)
		mp4mymenulist.Add(createitemmymenu("ico_pencil","意见反馈",100%x,nH),nH,comm.S_FEEDBACK)
		mp4mymenulist.Add(createitemmymenu("ico_setting","设置",100%x,nH),nH,comm.S_SETTING)
		mp4mymenulist.Add(createitemmymenu_phone("ico_call","客服电话",100%x,nH),nH,comm.S_CLIENTPHONE)
		mp4mymenulist.Add(createitemmymenu("ico_user","退出登录",100%x,nH),nH,comm.S_LOGOUT)
		If mi.headimg.Length>0 Then
			comm.loadimg(mi.headimg,mp4myheader)
		Else
			comm.loadimg(comm.S_TESTMYHEADER,mp4myheader)
		End If
'		If File.Exists(actModifyMyInfo.sDir,actModifyMyInfo.sName) Then
'			comm.loadimg_nocache("file://"&File.Combine(actModifyMyInfo.sDir,actModifyMyInfo.sName),mp4myheader)
'		Else
'			comm.loadimg(comm.S_TESTMYHEADER,mp4myheader)
'		End If
		
		mp4myinfofavteachernumlbl.Text=mi.favTeacherNum&"位"
		mp4myinfoordernumlbl.Text=mi.ordNum&"个"
		mp4myinfoyhqnumlbl.Text=mi.yhqNum&"张"
		mp4myinfoyuelbl.Text=mi.yue&"元"
		mp4mynickname.Text=mi.usertel
	Else
		'未登录
		mps(3).LoadLayout("mp4")
		mp4mymenulist.Clear
		mp4mymenulist.Add(createitemmymenu("ico_share","推荐给好友",100%x,nH),nH,comm.S_SHARE)
		mp4mymenulist.Add(createitemmymenu("ico_compare","在线比价",100%x,nH),nH,comm.S_COMPARE_PRICE)
		mp4mymenulist.AddCustomDivider(nDivH)
		mp4mymenulist.Add(createitemmymenu("ico_news","新闻动态",100%x,nH),nH,comm.S_NEWS)
		mp4mymenulist.Add(createitemmymenu("ico_pencil","意见反馈",100%x,nH),nH,comm.S_FEEDBACK)
		mp4mymenulist.Add(createitemmymenu("ico_setting","设置",100%x,nH),nH,comm.S_SETTING)
		comm.loadimg(comm.S_TESTMYHEADER,mp4myheader)
		mp4mymenulist.Add(createitemmymenu_phone("ico_call","客服电话",100%x,nH),nH,comm.S_CLIENTPHONE)
	End If
	'单独添加电话
	
	
	
End Sub
Sub mp4btnlogin_Click
	StartActivity(actLogin)
'	g_store.conf.Put("islogin",True)
'	fillmyinfo	
End Sub
'注册成功后保留cookies即可不用再登陆
Sub mp4btnregister_Click
	StartActivity(actRegister)
End Sub
Private Sub CallLogout
	ParseHelper.doGetReq(Me,"logout",comm.getApi(comm.apiIdx.LOGOUT),Null)
	g_store.conf.Remove("cookie")
	g_store.conf.Put("islogin",False)
	'退出jmsg
	Starter.jmsg.logout
	fillmyinfo
End Sub
Sub JobDone(thj As HttpJob)
	ProgressDialogHide
	If thj.Success Then
		Dim str As String=thj.GetString
		Dim nr As netRes=ParseHelper.getStatusData(str)
		Select thj.JobName
		Case "logout"
			Log("已退出登录")
		Case "refushmyinfo"
			If nr.nCode=200 Then
				'Log("updatemyinfo")
				ParseHelper.parseMyInfo(str)
				'更新数据
				mi=g_store.conf.Get("myinfo")
				mp4myinfofavteachernumlbl.Text=mi.favTeacherNum&"位"
				mp4myinfoordernumlbl.Text=mi.ordNum&"个"
				mp4myinfoyhqnumlbl.Text=mi.yhqNum&"张"
				mp4myinfoyuelbl.Text=mi.yue&"元"
				mp4mynickname.Text=mi.usertel
				comm.L(mi)
			End If
		Case "searchtec"
			If nr.nCode=200 Then
				g_store.conf.Put("searchtec",	ParseHelper.parseTeacher(str))
				StartActivity(actSearchTeacher)
			Else
				comm.TL("搜索教师错误:"&nr.sData)
			End If
		Case "reqkclst"
			parseKCLst(str)
		End Select
	Else
		comm.TL("网络错误:"&thj.ErrorMessage)
	End If
	thj.Release
	
End Sub
Sub mp4mymenulist_ItemClick (Index As Int, Value As Object)
	Dim iFlag As Int=Value
	Select iFlag
		Case comm.S_LOGOUT
			If Msgbox2("确定要退出登录吗?","退出","确定","取消","",Null)==DialogResponse.POSITIVE Then
				ToastMessageShow("退出登录",False)
				CallLogout
			End If
		Case comm.S_COMPARE_PRICE
			Dim wv As wvUrl
			wv.Initialize
			wv.Url="www.czhuan.xyz"
			comm.startWV(wv)
		Case comm.S_CLIENTPHONE
			Dim pi As Intent
			pi.Initialize(pi.ACTION_VIEW,"tel:"&comm.S_CLIENTPHONENUMBER)
			StartActivity(pi)
		Case comm.S_PERSONALINFO
			StartActivity(actModifyMyInfo)
		Case comm.S_NEWS
			StartActivity(actNewsList)
		Case comm.S_FEEDBACK
			StartActivity(actFeedBack)
		Case comm.S_SETTING
			StartActivity(actSetting)
		Case comm.S_KECHENGRATE
			StartActivity(actMyEvalList)
		Case comm.S_SHARE
			'comm.sharestr("欢迎使用靠谱家教app")
			oks1.init("oks",comm.SHARE_APPKEY,comm.getShareSdkCfgList)
			oks1.Text="欢迎使用靠谱家教app"
			oks1.Title="靠谱家教"
			oks1.TitleUrl=comm.S_WEBSITE
			oks1.Comment="欢迎使用靠谱家教app"
			oks1.Site="靠谱家教"
			oks1.SiteUrl=comm.S_WEBSITE
			oks1.Url=comm.S_WEBSITE
			oks1.setDialogMode
			oks1.disableSSOWhenAuthorize
			oks1.Silent=True
			oks1.show
	End Select
	
End Sub

Private Sub reqSearch(str As String)
	ProgressDialogShow2("正在搜索",True)
	g_store.conf.Put("searchkeyword",str)
	ParseHelper.doGetReq(Me,"searchtec",comm.getApi(comm.apiIdx.SEARCHTEACHER),Array As String("name",str))
End Sub
Sub ptitleedtsearchteacher_EnterPressed
	If ptitleedtsearchteacher.Text.Length>1 Then
		reqSearch(ptitleedtsearchteacher.Text.Trim)
		'StartActivity(actSearchTeacher)
	End If
End Sub
Sub mp4myinfoyhq_Click
	StartActivity(actYhqList)
End Sub

Sub mp4myinfofavteacher_Click
	StartActivity(actMyfavTeacherList)
End Sub

Sub mp4myinfopyue_Click
	StartActivity(actAccountRemain)
End Sub

Sub mp4myinfoporder_Click
	StartActivity(actOrderList)
End Sub

#end region
